<?php

namespace app\admin\command;

use think\console\Command;
use think\console\Input;
use think\console\Output;
use think\Db;

class HandleMemberTime extends Command
{

    protected function configure()
    {
        // 指令配置
        $this->setName('HandleMemberTime')
            ->setDescription('处理会员到期时间');
    }


    protected function execute(Input $input, Output $output)
    {
        $vip_config = Db::name('config')->where('name', 'in', ['TrialMember', 'member'])->select();
        foreach ($vip_config as $k => $v) {
            $list = Db::name('user')->where('member_make_time', '<', strtotime('-' . $v->value . ' days'))->select();
            foreach ($list as $item) {
                setMemberTypeByGroup_id($item->id, 1);
            }
        }
    }
}